package fr.univlille1.ftp;

import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	private static File baseDir;
	
	public static void main(String args[]){
		/* Traitement de l'ouverture des dossiers */
		Server.baseDir = new File(args[0]);
		/* Gestion des connexions entrantes */
		try{
			ServerSocket ss = new ServerSocket(2000);
			System.out.println("Server running");
			while(true){
				Socket s = ss.accept();
				new FTPRequest(s, args[1]).start();
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public static File getBaseDir(){
		return new File(Server.baseDir.getPath());
	}

}
